/**
* @file drv_i2c.h
* @brief  i2c driver
* @details 
* @author huangbin
* @version V1.0.0
* @date 2025-05-10
* @copyright All documents are copyrighted by Shenzhen Xinlongwei Technology Co., LTD.
*            They may not be used for commercial purposes without permission
*/
#ifndef __DRV_I2C_H__
#define	__DRV_I2C_H__

#ifdef __cplusplus
 extern "C" {
#endif /* __cplusplus */
////////////////////////////////////////////////////////////
#define I2C_SDA_PORT_CLK        RCC_APB2Periph_GPIOB
#define I2C_SDA_PORT GPIOB
#define I2C_SDA_PIN  GPIO_Pin_9

#define I2C_CLK_PORT_CLK        RCC_APB2Periph_GPIOB
#define I2C_CLK_PORT GPIOB
#define I2C_CLK_PIN  GPIO_Pin_8


#define I2C_SDA_HIGH()		I2C_SDA_PORT->BSRR = I2C_SDA_PIN
#define	I2C_SDA_LOW()		I2C_SDA_PORT->BRR = I2C_SDA_PIN

#define I2C_CLK_HIGH()		I2C_CLK_PORT->BSRR = I2C_CLK_PIN
#define	I2C_CLK_LOW()		I2C_CLK_PORT->BRR = I2C_CLK_PIN


typedef enum
{
	I2C_ACK  = 0,
	I2C_NAK = 1,
}I2C_ACK_STATUS;

/*!
 * \brief i2c initial
 */
extern void I2c_Init(void);
/*!
 * \brief i2c start
 */
extern void I2c_Start(void);
/*!
 * \brief i2c stop
 */
extern void I2c_Stop(void);
/*!
 * \brief i2c Write byte
 * \param[in] byte input data
 */
extern I2C_ACK_STATUS I2c_WriteByte(uint8_t byte);
/*!
 * \brief i2c start
 * \param[in] ack true=send ack,flase=no ack
 */
extern uint8_t I2c_ReadByte(I2C_ACK_STATUS ack);

//////////////////////////////////////////////////////////////////////////

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif 

